# 导入进程模块
import multiprocessing
import time


# 编写代码
def coding():
    for i in range(3):
        print("coding...")
        time.sleep(0.2)


# 听音乐
def music():
    for i in range(3):
        print("music...")
        time.sleep(0.2)


if __name__ == '__main__':
    # coding()
    # music()
    # 通过进程类创建进程对象
    coding_process = multiprocessing.Process(target=coding)
    # 通过进程类创建进程对象
    music_process = multiprocessing.Process(target=music)
    # 启动进程
    coding_process.start()
    music_process.start()

""""
小结：
1. 导⼊进程包
    import multiprocessing
2.  创建⼦进程并指定执⾏的任务
    sub_process = multiprocessing.Process (target=任务名)
3.启动进程执⾏任务
    sub_process.start()    
"""
